//
//  SnapKit.swift
//  SnapKitExtension
//
//  Created by point on 2018/5/29.
//  Copyright © 2018年 whiteboard. All rights reserved.
//

import UIKit
import SnapKit







func snapKitFit(_ val:CGFloat) -> CGFloat{
    let width = UIScreen.main.bounds.size.width
    let height = UIScreen.main.bounds.size.height
    return val * (width < height ? width:height ) / 375
}

extension  ConstraintMakerEditable {
    /// 设置偏移量 offset
    @discardableResult
    public func jOffset(_ amount: CGFloat) -> ConstraintMakerEditable {
        return self.offset(snapKitFit(amount))
    }
    
    /// 设置偏移量 inset
    @discardableResult
    public func jInset(_ amount: CGFloat) -> ConstraintMakerEditable {
        return self.inset(snapKitFit(amount ))
    }
}

extension ConstraintMaker {
    
    /// 设置宽
    func jWidth (_ val:CGFloat) {
        self.width.equalTo(snapKitFit(val) as ConstraintRelatableTarget)
    }
    
    /// 设置高
    func jHeight (_ val:CGFloat) {
        self.height.equalTo(snapKitFit(val) as ConstraintRelatableTarget)
    }
    
    /// 设置大小
    func jSize (_ val:CGSize) {
        self.size.equalTo(CGSize(width: snapKitFit(val.width), height: snapKitFit(val.height)))
    }
    
}



